

<!-- 活动专区 -->
<template>
	<view>
		<!-- header部分 -->
		<view class='header-Container header-height'>
			<view class="header-bg"></view>
			{{areaName}}==
			<navHeader :pageTitle="areaName" rightBtnType="msgCenter" colorTheme="white" @toggleMenuListHandler="toggleMenuListHandler">
			</navHeader>
		</view> 
		
		
		<!-- 大图列表 -->
		<view class="good_list" v-if="listType==0">
			<goodList v-if="goodsList && goodsList.length" :list='goodsList'></goodList>
			<g-empty v-else></g-empty>
		</view>
		
	
		<!-- 详情菜单 -->
		<view v-if="showDetailMenu" @click="toggleMenuListHandler()" class="detailMenu-Container">
			<detailMenu></detailMenu>
		</view>
	</view>
</template>

<script>
	import goodList from '@/components/goodList/goodList';
	import goodListtransverse from '@/components/goodList/goodList-transverse';
	import navbar from '@/components/navbar/navbar';
	import navHeader from '@/components/nav-header/nav-header';
	import detailMenu from "@/components/detailMenu/detailMenu";
	
	export default {
		components: {
			goodList,
			navbar,
			goodListtransverse,
			navHeader,
			detailMenu
		},
		data() {
			return {
				icon:{ 
					delete: '/pagesGoods/static/images/list/delete.png',
					return: '/pagesGoods/static/images/common/return-white.png',
					top: '/pagesGoods/static/images/index/top.png',
					search: '/pagesGoods/static/images/index/search.png',
					msgCenterWhite: '/pagesGoods/static/images/common/msg-center-white.png'
				},
				
				//详情菜单
				showDetailMenu: false,
				
				areaId: "",
				areaName: "",
				
				//筛选条件
				sortType: 0,
				listType: 0,
				areaId: "",
				goodsList: [], 
				
				//分页相关
				pageNum: 1,
				pageSize: 10
			};
		},

		onLoad(options) {
			this.areaId = options.areaId;
			this.areaName = options.areaName;
			this.getAreaGoodsList_fun();
		},
		onShow() {
			this.showDetailMenu = false;
		},
		methods: {
			
			//详情菜单
			toggleMenuListHandler() {
				this.showDetailMenu = !this.showDetailMenu;
			},
			
			//列表筛选条件
			tabClick(params) {
				
				if(params.listFlag) {
					this.listType = params.listType;
				}else if(params.sortFlag) {
					if(params.sortType == 3) {
						this.sortType = params.priceSort;
					}else {
						this.sortType = params.sortType;
					}
					
					this.pageNum = 1;
					this.getAreaGoodsList_fun();
				}
			},
			
			
			//商品列表
			getAreaGoodsList_fun() {
				
				var that = this;
				that.$api.globalUtil.requestAjax({
					url: '/areaGoodsApi/findAreaGoodsByAreaIdApi',
					method: "POST",
					data: {
						areaId: that.areaId,
						pageNum: that.pageNum, //页码
						pageSize: that.pageSize,//显示条数
						sort: that.sortType, //综合排序:null 销量排序:1 新品排序:2 价格ASC:3 价格DESC:4
					},
					success: function(res) {
						if(res.data.success) {
							
							if(res.data.response.results.length) {
								if(that.pageNum == 1) {
									that.goodsList = res.data.response.results;
								}else {
									that.goodsList = that.goodsList.concat(res.data.response.results);
								}
							}else {
								that.$api.msg("没有更多数据了！");
							}
						}
					}
				});
			}
		},
		onPullDownRefresh() {
			var that = this;
			that.pageNum = 1;
			
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1500);
			
			that.getAreaGoodsList_fun();
		},
		onReachBottom() {
			var that = this;
			that.pageNum = that.pageNum + 1;
			
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1500);
			
			that.getAreaGoodsList_fun();
		}
	}
</script>

<style lang="scss">
	.all-goods{
		margin: 0 auto;
		margin-top: 20rpx;
		width: 690rpx;
	}
	
	// header部分
	.header-Container {
		width: 100%;
		height: 176rpx;
		overflow: hidden;
		box-shadow: 0px 1rpx 1rpx 0px rgba(0, 0, 0, 0.08);
		background: rgba(255, 255, 255, 1);
		
		.header-bg {
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
			height: 100%;
			background:#FE5E49;
		}
	
		.leftBtns {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
	
			.back {
				margin-left: 17rpx;
				width: 44rpx;
				height: 44rpx;
			}
		}
	
		.title {
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
			line-height: 86rpx;
			text-align: center;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: rgba(51, 51, 51, 1);
		}
	}
	
	
	//专区列表
	/deep/.list-pages {
		margin-top: 30rpx;
		padding: 0 30rpx;
		
		.list-block {
			margin-bottom: 30rpx;
			width: 336rpx;
			box-shadow: 0 2rpx 10rpx 0 rgba(103,103,103,0.1);
			border-radius:10rpx;
			
			.list-poster {
				width: 336rpx;
				height: 336rpx;
			}
		}
	}
	.good_list2 {
		width: 100%;
		padding: 0 0 0 38rpx;
		background-color: white;
	}
	
</style>




